<template>
  <el-container class="home-container">
    <!--头部区域-->
    <el-header>
      <div>
        <img src="../assets/OIP.jpg" width="200px" alt="">
        <span>EDA远程实境实验管理系统 学生端</span>
      </div>
      <el-button type="danger" @click="logout">退出</el-button>
    </el-header>
    <!-- 页面主体区域-->
    <el-container>
      <!--侧边栏-->
      <el-aside :width="isCollapse ? '64px' : '200px'">
        <!--折叠-->
        <div class="toggle-button" @click="toggleCollapse">|||</div>
        <!--侧边菜单-->
        <el-menu background-color="#09233c" text-color="#fff" active-text-color="#3a8ee6"
                 :collapse="isCollapse" :collapse-transition="false" :router="true" :default-active="$route.path">
          <!-- 一级菜单 -->
          <el-menu-item index="/guide" >
            <!-- 一级菜单模板 -->
            <i class="el-icon-s-home"></i>
            <span slot="title">使用指南</span>
          </el-menu-item>

            <el-menu-item index="/myCourse" >
            <!-- 一级菜单模板 -->
            <i class="el-icon-collection"></i>
            <span slot="title">我的课程</span>
          </el-menu-item>

          <el-menu-item index="/myExp">
            <!-- 一级菜单模板 -->
            <i class="el-icon-menu"></i>
            <span slot="title">实验项目</span>

          </el-menu-item>
          <el-menu-item index="/simulation">
            <!-- 一级菜单模板 -->
            <i class="el-icon-cpu"></i>
            <span slot="title">虚拟仿真</span>

          </el-menu-item>
          <el-menu-item index="/remote">
            <!-- 一级菜单模板 -->
            <i class="el-icon-s-platform"></i>
            <span slot="title">远程实验</span>

          </el-menu-item>
<!--          <el-menu-item index="/videoTest">-->
<!--            &lt;!&ndash; 一级菜单模板 &ndash;&gt;-->
<!--            <i class="el-icon-s-platform"></i>-->
<!--            <span slot="title">视频测试</span>-->

<!--          </el-menu-item>-->
          <el-submenu index="/report">
            <template slot="title">
            <i class="el-icon-document"></i>
            <span >实验报告</span>
            </template>
            <el-menu-item-group>

            <el-menu-item index="/edit">
              <i class="el-icon-edit"></i>
              <span slot="title">编辑报告</span>
            </el-menu-item>
            <el-menu-item index="/inquire">
              <i class="el-icon-view"></i>
              <span slot="title">成绩查询</span>
            </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!-- 内容主体区域-->
      <el-main>
        <!--路由占位符-->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: 'Home',
  data () {
    return {
      isCollapse: false
      // userInfo: '',
    }
  },
  created () {
    // this.$getUserInfo()
  },
  mounted () {
  },
  methods: {
    async logout () {
      const flag = await this.$confirm('确认要退出吗')
      if (flag) {
        // 清空redis token
        const { data: res } = await this.$http.post('/logout')
        // 清空token
        window.sessionStorage.clear()
        console.log(res)
        // 跳转登录页
        await this.$router.push('/login')
      }
    },
    toggleCollapse () {
      this.isCollapse = !this.isCollapse
    }
  }
}
</script>

<style lang="less" scoped>
@import "../assets/css/home.less";
</style>
